-- msg_auth_account_result
-- Create by panyl
-- 通知账号验证结果

return function(lpc)
    trace("msg_auth_account_result", "账号验证结果，results：%d，auth_key：%d，msg：%s", lpc.result, lpc.auth_key, getDialogStr(lpc.msg));

    _G.aaaAccountInfo.auth_key    = lpc.auth_key
    _G.aaaAccountInfo.auth_result = lpc.result
    _G.aaaAccountInfo.msg         = getDialogStr(lpc.msg)


    -- 如果成功了
    if LOGIN_AUTH_OK ~= lpc.result then
        return;
    end

    local para = lpc.para or {};

    -- 1. 如果有绑定账号
    if para.bind_accounts then
        AccountM.setBindAccounts(para.bind_accounts);

        -- -- 如果是使用游客登录，则提示玩家使用绑定账号登录
        -- local v = _G.aaaAccountInfo
        -- local platform = v["extra_para"]["3rdplatform"];
        -- if platform ~= nil and string.find(platform, "guest") then
        --     EventMgr.fire(event.GUEST_ACCOUNT_BINDED);
        --     return;
        -- end
    end

    -- 2. aaaId
    trace("msg_auth_account_result", "服务器aaa_id:%d", para.aaa_id);

    _G.aaaAccountInfo.AAA_ID = para.aaa_id;

    -- 记录到UserDefault.xml里
    UserDefaultM.setStringForKey("aaa_id", para.aaa_id);

    -- 3. 服务器ip、port
    local info = para.server_info;

    trace("msg_auth_account_result", "获取服务器信息:\n(%s,%d)", info.ip, info.port);

    -- 服务器ip、端口记下
    local server_ip = info.ip;

    if _G["use_pure_ip"] and info["pure_ip"] then
        server_ip = info["pure_ip"];
    end

    _G.aaaAccountInfo.server_ip   = server_ip
    _G.aaaAccountInfo.server_port = info.port

    trace("msg_auth_account_result", "获取门票结果: %d", lpc.result);

    _G.aaaAccountInfo.seed = para.seed
    _G.aaaAccountInfo.privilege = lpc.privilege
    _G.server_name = info.server;

    -- 断开与aaa的链接
    Socket.disconnect();
end
